<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  
  <xs:simpleType name="SystemTypes">
    <xs:restriction base="xs:string">
	  <xs:enumeration value="System.Boolean"/>
	  <xs:enumeration value="System.Byte"/>
	  <xs:enumeration value="System.Char"/>
	  <xs:enumeration value="System.DateTime"/>
	  <xs:enumeration value="System.Decimal"/>
	  <xs:enumeration value="System.Double"/>	  
	  <xs:enumeration value="System.Int16"/>
	  <xs:enumeration value="System.Int32"/>
	  <xs:enumeration value="System.Int64"/>
	  <xs:enumeration value="System.SByte"/>
	  <xs:enumeration value="System.String"/>
	  <xs:enumeration value="System.Single"/>
	  <xs:enumeration value="System.TimeSpan"/>
	  <xs:enumeration value="System.UInt16"/>
	  <xs:enumeration value="System.UInt32"/>
	  <xs:enumeration value="System.UInt64"/>	  
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="VersionNumber">
    <xs:restriction base="xs:string">
	  <xs:pattern value="[0-9].[0-9].[0-9].[0-9]"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:element name="Mission">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Specification"/>
        <xs:element ref="Blueprint"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Specification">
    <xs:complexType>
      <xs:sequence>
		  <xs:element name="Name" type="xs:string"/>
		  <xs:element name="Version" type="VersionNumber"/>
		  <xs:element name="Author" type="xs:string"/>
		  <xs:element name="Description" type="xs:string"/>
		  <xs:element name="Tags" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Blueprint">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Plugin" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Plugin">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Input"/>
        <xs:element ref="Output" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="Name" type="xs:string" use="required"/>
      <xs:attribute name="Version" type="VersionNumber" use="required"/>
      <xs:attribute name="File" type="xs:string" use="required"/>
      <xs:attribute name="ID" type="xs:integer" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="Input">
    <xs:complexType>
      <xs:sequence>
		<xs:element ref="LinkedPackage" minOccurs="0" maxOccurs="unbounded"/>
		<xs:element ref="Package" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Output">
    <xs:complexType>
      <xs:sequence>
		<xs:element ref="DynamicPackage" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="Package" minOccurs="0" maxOccurs="unbounded"/>
	  </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="LinkedPackage">
    <xs:complexType>
      <xs:attribute name="Name" type="xs:string" use="required"/>
      <xs:attribute name="FromPluginID" type="xs:integer" use="required"/>
      <xs:attribute name="FromPackage" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="DynamicPackage">
    <xs:complexType>
      <xs:attribute name="Name" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="Package">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Sequence" minOccurs="0"/>
        <xs:element ref="Data" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="Name" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="Sequence">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Column" minOccurs="1" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Column">
    <xs:complexType>
      <xs:all>
        <xs:element ref="Validation" minOccurs="0"/>
        <xs:element ref="Description"/>
	  </xs:all>
      <xs:attribute name="Name" type="xs:string" use="required"/>
      <xs:attribute name="Type" type="SystemTypes" use="required"/>
      <xs:attribute name="DefaultValue" type="xs:string"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="Validation" type="xs:string"/>
  <xs:element name="Description" type="xs:string"/>
  <xs:element name="Data">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Row" minOccurs="1" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Row" />
</xs:schema>